package self.hoy.demo.cloud.conf;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import self.hoy.demo.cloud.ITestContext;
import self.hoy.demo.cloud.MyContextBean;

/**
 * @author 三共小不
 * @date 2021/7/5
 */
@Configuration
@EnableConfigurationProperties
public class TestContextAutoConfiguration {
    String client = "test0";

    @Value("${textcontext.name:hello}")
    String name;

    @Autowired
    TestBean testBean;

    @Bean
    @ConditionalOnMissingBean
    public ITestContext getTestContext() {
        System.out.println(testBean.getName());
        return new MyContextBean(client + " : " + name);
    }
}
